﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;

namespace Lanworks
{
    public partial class Branch : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BBranch bBranch = new BBranch();
                DataSet dsBranch = bBranch.GetAllBranch();
                GvBranch.DataSource = dsBranch;
                GvBranch.DataBind();
            }
        }

        protected void btnSubmitBranch_Click(object sender, EventArgs e)
        {
            BBranch bBranch = new BBranch();
            string sBranchName = txtBranchName.Text.Trim();
            if (!bBranch.IsExistBranch(sBranchName))
            {
                bBranch.InsertBranch(sBranchName);
                lbResult.Text = "Insert branhc sussessfull. Refesh page to show new row";
            }
            else
                lbResult.Text = "This branch is exist in system. Please choose other branch name";
        }

    }
}